home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / timing.arc / TIMETEST.BAS < prev    next >
BASIC Source File  |  1987-10-01  |  2KB  |  47 lines

  1. '*** This program does nothing more than demonstrate the two timing
  2. '***    SubPrograms, DELAY & BGDELAY
  3.  
  4. '*** First, the simpler DELAY.  This SubProgram is CALLed with one
  5. '***   SINGLE PRECISION (*!*) argument and retains control until that
  6. '***   many hundredths of seconds pass.
  7.  
  8. color 14        :print "First test: `hard' delay"
  9. color 7         :print "   how many hundredths of seconds? :";
  10. locate ,,1      :line input tmp$
  11. print "   Starting time: ";time$
  12. time.to.wait! = val(tmp$)             'wait for 5 seconds
  13. call delay(time.to.wait!)
  14. print "   Ending time  : ";time$
  15.  
  16.  
  17. '*** Next, BGDELAY.  This SubProgram is CALLed with two SINGLE PRECISION (*!*)
  18. '***   arguments, and one integer argument: the first S.P. argument tells
  19. '***   BGDELAY how many hundredths of seconds are to be delayed; the second
  20. '***   S.P. argument is for BGDELAY to tell you how many hundredths of
  21. '***   seconds remain until the timeout has occurred.  The third argument, the
  22. '***   integer, tells you whether or not the timing is continuing.  Once the
  23. '***   third argument falls to 0, the timing is done (ie, a timeout has
  24. '***   occurred) less than or equal to 0, then the timeout has occurred!
  25.  
  26. print
  27. color 14        :print "Next test: `background' delay"
  28. color 7         :print "   how many hundredths of seconds? :";
  29. locate ,,1      :line input tmp$
  30. print "   Starting time: ";time$
  31. time.to.wait! = val(tmp$)             'wait for 5 seconds
  32.  
  33. do
  34.         gosub mything                   'go do your thing while waiting
  35.         call bgdelay (time.to.wait!,time.to.go!,st%)
  36. loop until st%=0
  37.  
  38. print
  39. print "   Ending time  : ";time$
  40. end
  41.  
  42. mything:
  43. 'do anything you want here, but DON'T change the value of ST% !!
  44. locate csrlin,1
  45. print "   Current time : ";time$,,"1/100 seconds left:";fix(time.to.go!);
  46. return
  47.